package controller

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"github.com/gin-gonic/contrib/sessions"
)

func Index(c *gin.Context)  {
	r := c.Request;
	c.HTML(http.StatusOK, "console/index/index.html", gin.H{"title":"主页", "path" : r.URL.Path})
}

func About(c *gin.Context)  {
	r := c.Request;
	c.HTML(http.StatusOK, "console/about/index.html", gin.H{"title":"关于页", "path" : r.URL.Path})
}

func SessionSet(c *gin.Context)  {
	session := sessions.Default(c)
	session.Set("name", "一师范")
	session.Save()
	c.String(http.StatusOK,"session设置成功")
}

func SessionGet(c *gin.Context)  {
	session := sessions.Default(c)
	name := session.Get("user_id")
	c.JSON(http.StatusOK,gin.H{"name" : name})
}